package com.chb.system.controller.apis;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.chb.system.annotation.OperLogAnnotation;
import com.chb.system.service.LoginInfoService;
import com.chb.system.vo.LoginInfoVo;
import com.hos.entity.sys.LoginInfo;
import com.hos.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ：张家琪
 * @date ：Created in 2023/12/18 10:58
 * @description：
 * @modified By：
 * @version:
 */
@RestController
@RequestMapping("system/api/loginInfo")
@Api(value = "登录日志接口", tags = "登录日志接口")
public class APILoginInfoServiceController {
    @Autowired
    private LoginInfoService loginInfoService;

    @GetMapping("getAllLoginInfo")
    @ApiOperation(value = "获取所有登录日志")
    public Result<List<LoginInfo>> getAllLoginInfo() {
        return new Result<>(200, "查询成功", loginInfoService.getAllLoginInfo());
    }

    @PostMapping("selectAllLoginInfoByCond")
    @ApiOperation(value = "条件查询登录日志")
    public Result<Page<LoginInfo>> selectAllLoginInfoByCond(@RequestBody LoginInfoVo loginInfoVo) {
        return new Result<>(200, "请求成功", loginInfoService.selectAllLoginInfoByCond(loginInfoVo));
    }

    @DeleteMapping("deleteLoginInfoByLoginInfoIds/{ids}")
    @ApiOperation(value = "根据访问ID永久删除登录日志")
    public Result<Integer> deleteLoginInfoByLoginInfoIds(@PathVariable List<Long> ids) {
        return new Result<>(200, "删除成功", loginInfoService.deleteLoginInfoByIds(ids));
    }

    @DeleteMapping("clearLoginInfo")
    @ApiOperation(value = " 清空登录日志")
    @OperLogAnnotation(business_type = "系统业务-清空登录日志", operator_type = 1)
    public Result<Integer> clearLoginInfo() {
        return new Result<>(200, "清空成功", loginInfoService.clearLoginInfo());
    }

}